

require("luci.sys")  
require("luci.sys.zoneinfo")  
require("luci.tools.webadmin")  


require("luci.config")  

local m,s,u

m = Map("wan_backup",translate("WAN Backup Policy"),translate("Configure Mater WAN Line"))
m:chain("luci")

s = m:section(TypedSection,"wan_backup",translate("policy"))
s.addremove = false
s.anonymous = true

local uci = require "luci.model.uci".cursor()
  



o = s:option( Flag, "enable", translate("Enable"),translate("Enable WAN backup policy"))  



o = s:option( Value, "change_delay", translate("Change Delay"),translate("Second"))  
o:depends("enable",1)
o.default=60
o = s:option(Value, "check_interval", translate("Check Interval"),translate("Second"))  
o:depends("enable",1)
o.datatype = "max(1800)"  
o.default = 5

o = s:option(Value, "rssi", translate("RSSI"),translate("Range 11 - 30"))  
o:depends("enable",1)
o.datatype = "range(11,30)"  
o.default = 20

o = s:option(Value, "target", translate("Target IP"))  
o:depends("enable",1)
o.rmempty = false
o.value="114.114.114.114"
o.datatype = "ip4addr"  


  

local apply = luci.http.formvalue("cbi.apply")
 if apply then
     io.popen("/etc/init.d/wan_backup restart")
end


return m